package 单例模式;

/**
 * 单例模式的狗
 *
 * @author ithuameng
 */
public class DogSingle {

    // 懒汉模式
    private static volatile DogSingle dogSingle = null;

    private DogSingle() {}

    public static DogSingle getInstance() {
        if (null == dogSingle) {
            synchronized(DogSingle.class) {
                if (null == dogSingle) {
                    dogSingle = new DogSingle();
                }
            }
        }
        return dogSingle;
    }


    // 饿汉模式
    // private static DogSingle dogSingle = new DogSingle();
    //
    // private DogSingle() {}
    //
    // public static DogSingle getInstance() {
    //     return dogSingle;
    // }
}
